﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Deployment.BuildManager.ExternalProcess.CreateSetupFile
{
    public class Program
    {
        [STAThread()]
        public static int Main(string[] args)
        {
            SetupApplication app = new SetupApplication();
            app.AdditionalCommandParameters = GetCommandParameters(args);
            app.ShutdownMode = System.Windows.ShutdownMode.OnExplicitShutdown;
            int exitCode = app.Run();
            return exitCode;
        }

        private static string GetCommandParameters(string[] args)
        {
            StringBuilder sb = new StringBuilder();
            foreach (string command in args)
            {
                string commandClean = command.Trim();

                if (!commandClean.StartsWith("/"))
                    commandClean += string.Format("/{0} ", commandClean);

                sb.Append(commandClean);
            }

            if (sb.Length > 0)
                return sb.ToString().TrimEnd();
            else
                return string.Empty;
        }
    }
}
